import { get, post } from '@/utils/request'

const prefix = 'order'

export default {
  /**
   * 节目列表
   */
  index: data => {
    return get(`${prefix}/default/index`, data)
  },
  /**
   * 节目列表
   */
  view: id => {
    return get(`${prefix}/default/view`, {
      id: id
    })
  },
  /**
   * 节目列表
   */
  adminView: id => {
    return get(`${prefix}/admin/view`, {
      id: id
    })
  },

  /**
   * 节目列表
   */
  delivery: data => {
    return get(`${prefix}/delivery/index`, data)
  },

  /**
   * 下载订单
   */
  download: data => {
    return post(`${prefix}/download/index`, data, {
      // responseType: 'arraybuffer',
      responseType: 'blob'
    })
  },
  /**
   * 订单发货
   */
  freight: (id, data) => {
    return post(`${prefix}/freight/deliver?id=${id}`, data, true)
  },

  /**
   * 订单发货
   */
  getFreightForm: id => {
    return get(`${prefix}/freight/deliver?id=${id}`)
  },

  /**
   * 更新发货信息
   */
  updateDeliveryForm: (data, id, postMethod = true) => {
    if (postMethod) {
      return post(`${prefix}/delivery/update?id=${id}`, data)
    } else {
      return get(`${prefix}/delivery/update?id=${id}`)
    }
  },

  /**
   * 批量发货
   */
  deliveryBatch: data => {
    return post(`${prefix}/delivery/batch`, data)
  },

  /**
   * 退款详情
   */
  refundView: id => {
    return get(`${prefix}/refund/view?id=${id}`)
  },
  /**
   * 退款处理-审核
   */
  refundHandle: (data, id) => {
    return post(`${prefix}/refund/handle?id=${id}`, data)
  },

  /**
   * 退款处理-审核
   */
  refundAudit: (data, id) => {
    return post(`${prefix}/refund/audit?id=${id}`, data)
  },

  /**
   * 退款处理-人工退款
   */
  refundManual: (data, id) => {
    return post(`${prefix}/refund/manual?id=${id}`, data)
  },

  /**
   * 服务详情
   */
  serviceView: id => {
    return get(`${prefix}/service/view?id=${id}`)
  },

  /**
   * 服务-审核
   */
  serviceAudit: (data, id) => {
    return post(`${prefix}/service/audit?id=${id}`, data)
  },

  /**
   * 服务-确认金额
   */
  serviceConfirm: (data, id) => {
    return post(`${prefix}/service/confirm?id=${id}`, data)
  },

  /**
   * 服务-操作
   */
  serviceHandle: (data, id) => {
    return post(`${prefix}/service/handle?id=${id}`, data)
  }
}
